<template>
    <div class="login_container">
      <div class="login_box">
        <!-- 表单 -->
        <el-form class="login_form" :model="formContent" :rules="loginFormRules" ref="loginFormRef">
          <h2 class="headline">用户注册</h2>
          <el-form-item prop="username">
            <el-input
              v-model="formContent.username"
              prefix-icon="el-icon-user-solid"
            ></el-input>
          </el-form-item>
          <el-form-item prop="password">
            <el-input
              v-model="formContent.password"
              prefix-icon="el-icon-lock"
              show-password
            ></el-input>
          </el-form-item>
          <!-- 按钮 -->
          <el-form-item class="btns">
            <el-button type="primary" @click="validateLoginForm">注册</el-button>
            <el-button type="info" @click="resetLoginForm">重制</el-button>
          </el-form-item>
          <el-form-item class="btns2">
            <el-link @click="ToLogin">直接登录</el-link>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </template>
  
  <script>
  export default {
    name: "register",
    data() {
      return {
        formContent: {
          username: "",
            password: "",
        },
        loginFormRules: {
          username: [
            { required: true, message: "请输入登录名称", trigger: "blur" },
            {
              min: 3,
              max: 10,
              message: "长度为3字符到10字符之间",
              trigger: "blur",
            },
          ],
          password: [
            { required: true, message: "请输入密码", trigger: "blur" },
            {
              min: 5,
              max: 15,
              message: "长度为5字符到15字符之间",
              trigger: "blur",
            },
              ],
              
        },
        loading: false,
      }
      },
    methods: {
        //重制表单
          resetLoginForm() {
              // console.log(this);
              this.$refs.loginFormRef.resetFields()
        },
          //校验通过
          validateLoginForm() {
              this.$refs.loginFormRef.validate(value => {
                  // console.log(value)
                if (!value) return;
                this.$router.push("/login");
                
              })
        },
          ToLogin() {
            this.$router.push("/login");
        }
    }
  };
  </script>
  
  <style lang="less" scoped>
  .login_container {
    background-color: rgb(11, 99, 166);
    height: 100vh;
    .login_box {
      width: 450px;
      height: 380px;
      background-color: #fff;
      border-radius: 20px;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      .from_content {
        background-color: pink;
      }
    }
  }
  .login_form {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
    .headline {
      text-align: center;
      margin-bottom: 35px;
    }
  }
  .btns {
    display: flex;
    justify-content: flex-end;
  }
  </style>
  